# -*- coding: UTF-8 -*-

import xeres

#
#	Defines script sources in uxml
#

# Source definition.
class SourceDef(object):
	def __init__( self, entry, filename ):

		self.source = entry.GetAttribute( 'source', '<inline:%s>' %filename )
		self.inline = entry.string.replace('\r\n','\n').strip()
		self.lang = entry.GetAttribute('lang')

		# Compile source
		# "InlineCode call will turn a code object into a memory module"
		self.members = xeres.InlineCode( '__event__' , compile(self.inline, self.source, 'exec') )
	
	def get( self, function ):
		return self.members.__dict__[ function ]
